package com.AEWMS.Servlet.Semester;

import com.AEWMS.Dao.Semester;
import com.AEWMS.Service.SemesterService;
import com.alibaba.fastjson.JSON;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;

@WebServlet(name = "getAllSemesterServlet", urlPatterns = "/getAllSemesterServlet")
public class getAllSemesterServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request, response);
    }

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //获取学期显示在下拉框
        SemesterService ss = new SemesterService();
        ArrayList<Semester> as = ss.findAllSemester();
        response.getWriter().println(JSON.toJSONString(as));
    }
}